<?php

class karyawan_edit extends CI_Model {

    private $QUERY = "SELECT a.*,b.divisi FROM mt_karyawan a LEFT JOIN mt_divisi b on (a.id_divisi=b.id_divisi) ";
    
    public function checkDupKey($colom, $value) {
        $gcd = new GCD();
        $gcd->set($this->QUERY);
        return $gcd->checkDuplicateKey($colom, $value);
    }

    public function addDataKaryawan($nik, $arrVals) {
        $this->db->insert('mt_karyawan', $arrVals);
    }

    public function updateDataKaryawan($nik, $arrVals) {
        $this->db->where('nik', $nik);
        $this->db->update("mt_karyawan", $arrVals);
    }

    public function getDataKaryawanDetil($kode) {
        $gcd = new GCD();

        $conds = "nik='" . $kode . "'";
        $gcd->set($this->QUERY);
        $row = $gcd->getSingleData($conds);

        $data = array();
                $this->data_config['nik'] = trim($row->nik);
                $this->data_config['id_divisi_karyawan'] = $row->id_divisi;
                $this->data_config['divisi_karyawan'] = $row->divisi;
                $this->data_config['nama'] = $row->nama;
                $this->data_config['nama_panggilan'] = $row->nama_panggilan;
                $this->data_config['tempat_lahir'] = $row->tempat_lahir;
                $this->data_config['tanggal_lahir'] = formatDB2Date($row->tanggal_lahir);
                $this->data_config['alamat'] = $row->alamat;
                $this->data_config['kota'] = $row->kota;
                $this->data_config['propinsi'] = $row->propinsi;
                $this->data_config['agama'] = $row->agama;
                $this->data_config['status_marital'] = $row->status_marital;
                $this->data_config['warga_negara'] = $row->warga_negara;
                $this->data_config['no_telepon'] = $row->no_telepon;
                $this->data_config['no_hp'] = $row->no_hp;
                $this->data_config['tanggal_masuk'] = formatDB2Date($row->tanggal_masuk);
                $this->data_config['email'] = $row->email;
                
        return $data;
    }


}

?>
